package org.wk.affiliate.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wk.affiliate.enums.NoticeStatus;
import org.wk.affiliate.service.NoticeService;
import org.wk.affiliate.view.NoticeVo;
import org.wk.core.common.view.PageVo;
import org.wk.core.common.view.ResponseVo;
import org.wk.logger.common.annotation.SysLog;

import java.util.Map;

/**
 * @author TangShenShen
 * @Description: 公告管理controller类
 * @date 2018/6/8 13:59
 */
@RestController
@RequestMapping("/notice")
public class NoticeController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private NoticeService noticeService;

    /**
     * 后台端  鲸拍公告列表
     * @return
     */
    @SysLog("公告管理列表")
    @RequestMapping(value="/list")
    public ResponseVo list(@RequestParam Map<String, Object> params) {
        PageVo page = noticeService.queryPage(params);
        return ResponseVo.success().addAttribute("page", page);
    }

    @SysLog("获取公告信息")
    @RequestMapping(value="/info/{noticeId}")
    public ResponseVo findNoticeInfo(@PathVariable String noticeId) {
        ResponseVo result = new ResponseVo();
        result = noticeService.selectById(noticeId);
        return result;
    }

    @SysLog("保存或更新公告")
    @RequestMapping(value="/saveOrUpdate")
    public String saveOrUpdate(@RequestBody NoticeVo noticeVo) {
        ResponseVo responseVo = noticeService.saveOrUpdate(noticeVo);
        return responseVo.toString();
    }

}
